"""
商品明细DTO

@author liaochangyi
@since 2025-01-25
"""

from typing import Dict, Any


class GoodsDetailDto:
    """商品明细DTO"""
    
    def __init__(self, goods_dict=None):
        """
        初始化商品明细
        
        Args:
            goods_dict: 商品明细字典
        """
        self.goods_id = None  # 商品编码
        self.wxpay_goods_id = None  # 微信侧商品编码
        self.goods_name = None  # 商品名称
        self.quantity = None  # 商品数量
        self.price = None  # 商品单价
        
        if goods_dict:
            self.goods_id = goods_dict.get('goods_id')
            self.wxpay_goods_id = goods_dict.get('wxpay_goods_id')
            self.goods_name = goods_dict.get('goods_name')
            self.quantity = goods_dict.get('quantity')
            self.price = goods_dict.get('price')
    
    def to_dict(self) -> Dict[str, Any]:
        """转换为字典格式"""
        return {
            'goods_id': self.goods_id,
            'wxpay_goods_id': self.wxpay_goods_id,
            'goods_name': self.goods_name,
            'quantity': self.quantity,
            'price': self.price
        } 